package P3.T13;

import java.util.*;

public class T13 {
    public static void main(String[] args) {
        Cat[] cats={
            new Cat(1,3),
                new Cat(5,18),
                new Cat(2,5),
                new Cat(8,7),
                new Cat(12,2),
                new Cat(4,10),
                new Cat(7,13),
        };
        Arrays.sort(cats,new CatWeightComparator());
        for(Cat cat:cats){
            System.out.println(cat);
        }
    }
}
class CatAgeComparator implements Comparator<Cat> {

    @Override
    public int compare(Cat o1, Cat o2) {
        return o1.getAge()-o2.getAge();
    }
}
class CatWeightComparator implements Comparator<Cat> {

    @Override
    public int compare(Cat o1, Cat o2) {
        return o1.getWeight()-o2.getWeight();
    }
}
class Cat{
    private int age;
    private int weight;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public Cat(int age, int weight) {
        this.age = age;
        this.weight = weight;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "age=" + age +
                ", weight=" + weight +
                '}';
    }
}